<!-- xml version="1.0" encoding="utf-8" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
	<title>Latin Verb Conjugator</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<link href="../classics.css" rel="stylesheet" type="text/css">
</head>

<?php

$endings = array();
function addEnding($type, $voice, $mood, $tense, $vI, $vthou, $vhe, $vwe, $vye, $vthey) {
	global $endings;
	$endings[$type][ $voice][$mood][$tense] = array('I' => $vI, 'thou' => $vthou, 'he' => $vhe,
		                                            'we' => $vwe, 'ye' => $vye, 'they' => $vthey);
}

addEnding('first', 'active', 'indicative', 'present', 'ō', 'ās', 'at', 'āmus', 'ātis', 'ant');
addEnding('first', 'passive', 'indicative', 'present', 'or', 'āris|āre', 'ātur', 'āmur', 'āminī', 'antur');
addEnding('first', 'active', 'subjunctive', 'present', 'em', 'ēs', 'et', 'ēmus', 'ētis', 'ent');
addEnding('first', 'passive', 'subjunctive', 'present', 'er', 'ēris|ēre', 'ētur', 'ēmur', 'ēminī', 'entur');

addEnding('first', 'active', 'indicative', 'imperfect', 'ābam', 'ābās', 'ābat', 'ābāmus', 'ābātis', 'ābant');
addEnding('first', 'passive', 'indicative', 'imperfect', 'ābar', 'ābāris|ābāre', 'ābātur', 'ābāmur', 'ābāminī', 'ābantur');
addEnding('first', 'active', 'subjunctive', 'imperfect', 'ārem', 'ārēs', 'āret', 'ārēmus', 'ārētis', 'ārent');
addEnding('first', 'passive', 'subjunctive', 'imperfect', 'ārer', 'ārēris|ārēre', 'ārētur', 'ārēmur', 'ārēminī', 'ārentur');

addEnding('first', 'active', 'indicative', 'future', 'ābō', 'ābis', 'ābit', 'ābimus', 'ābitis', 'ābunt');
addEnding('first', 'passive', 'indicative', 'future', 'ābor', 'āberis|ābere', 'ābitur', 'ābimur', 'ābiminī', 'ābuntur');

addEnding('first', 'active', 'indicative', 'perfect', 'ī', 'istī', 'it', 'imus', 'istis', 'ērunt|ēre');
addEnding('first', 'passive', 'indicative', 'perfect', 'us sum', 'us es', 'us est', 'ī sumus', 'ī estis', 'ī sunt');
addEnding('first', 'active', 'subjunctive', 'perfect', 'erim', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('first', 'passive', 'subjunctive', 'perfect', 'us sim', 'us sīs', 'us sit', 'ī sīmus', 'ī sītis', 'ī sint');

addEnding('first', 'active', 'indicative', 'pluperfect', 'eram', 'erās', 'erat', 'erāmus', 'erātis', 'erant');
addEnding('first', 'passive', 'indicative', 'pluperfect', 'us eram', 'us erās', 'us erat', 'ī erāmus', 'ī erātis', 'ī erant');
addEnding('first', 'active', 'subjunctive', 'pluperfect', 'issem', 'issēs', 'isset', 'issēmus', 'issētis', 'issent');
addEnding('first', 'passive', 'subjunctive', 'pluperfect', 'us essem', 'us essēs', 'us esset', 'ī essēmus', 'ī essētis', 'ī essent');

addEnding('first', 'active', 'indicative', 'future perfect', 'erō', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('first', 'passive', 'indicative', 'future perfect', 'us erō', 'us eris', 'us erit', 'ī erimus', 'ī eritis', 'ī erunt');

$endings['first']['active']['imperative']['present']['thou'] = 'ā';
$endings['first']['passive']['imperative']['present']['thou'] = 'āre';
$endings['first']['active']['imperative']['present']['ye'] = 'āte';
$endings['first']['passive']['imperative']['present']['ye'] = 'āminī';
$endings['first']['active']['imperative']['future']['thou'] = 'ātō';
$endings['first']['passive']['imperative']['future']['thou'] = 'ātor';
$endings['first']['active']['imperative']['future']['ye'] = 'ātōte';
$endings['first']['active']['imperative']['future']['he'] = 'ātō';
$endings['first']['passive']['imperative']['future']['he'] = 'ātor';
$endings['first']['active']['imperative']['future']['they'] = 'antō';
$endings['first']['passive']['imperative']['future']['they'] = 'antor';

$endings['first']['active']['infinitive']['present'] = 'āre';
$endings['first']['passive']['infinitive']['present'] = 'ārī';
$endings['first']['active']['infinitive']['future'] = 'ūrus esse';
$endings['first']['passive']['infinitive']['future'] = 'um īrī';
$endings['first']['active']['infinitive']['perfect'] = 'isse';
$endings['first']['passive']['infinitive']['perfect'] = 'us esse';


$endings['first']['participle']['present'] = 'āns';
$endings['first']['participle']['future'] = 'ūrus';
$endings['first']['participle']['perfect'] = 'us';
$endings['first']['participle']['gerundive'] = 'andus';

$endings['first']['gerund']['genitive'] = 'andī';
$endings['first']['gerund']['dative'] = 'andō';
$endings['first']['gerund']['accusative'] = 'andum';
$endings['first']['gerund']['ablative'] = 'andō';


$endings['first']['supine']['accusative'] = 'um';
$endings['first']['supine']['ablative'] = 'ū';


addEnding('second', 'active', 'indicative', 'present', 'eō', 'ēs', 'et', 'ēmus', 'ētis', 'ent');
addEnding('second', 'passive', 'indicative', 'present', 'eor', 'ēris|ēre', 'ētur', 'ēmur', 'ēminī', 'entur');
addEnding('second', 'active', 'subjunctive', 'present', 'eam', 'eās', 'eat', 'eāmus', 'eātis', 'eant');
addEnding('second', 'passive', 'subjunctive', 'present', 'ear', 'eāris|eāre', 'eātur', 'eāmur', 'eāminī', 'eantur');

addEnding('second', 'active', 'indicative', 'imperfect', 'ēbam', 'ēbās', 'ēbat', 'ēbāmus', 'ēbātis', 'ēbant');
addEnding('second', 'passive', 'indicative', 'imperfect', 'ēbar', 'ēbāris|ēbāre', 'ēbātur', 'ēbāmur', 'ēbāminī', 'ēbantur');
addEnding('second', 'active', 'subjunctive', 'imperfect', 'ērem', 'ērēs', 'ēret', 'ērēmus', 'ērētis', 'ērent');
addEnding('second', 'passive', 'subjunctive', 'imperfect', 'ērer', 'ērēris|ērēre', 'ērētur', 'ērēmur', 'ērēminī', 'ērentur');

addEnding('second', 'active', 'indicative', 'future', 'ēbō', 'ēbis', 'ēbit', 'ēbimus', 'ēbitis', 'ēbunt');
addEnding('second', 'passive', 'indicative', 'future', 'ēbor', 'ēberis|ēbere', 'ēbitur', 'ēbimur', 'ēbiminī', 'ēbuntur');

addEnding('second', 'active', 'indicative', 'perfect', 'ī', 'istī', 'it', 'imus', 'istis', 'ērunt|ēre');
addEnding('second', 'passive', 'indicative', 'perfect', 'us sum', 'us es', 'us est', 'ī sumus', 'ī estis', 'ī sunt');
addEnding('second', 'active', 'subjunctive', 'perfect', 'erim', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('second', 'passive', 'subjunctive', 'perfect', 'us sim', 'us sīs', 'us sit', 'ī sīmus', 'ī sītis', 'ī sint');

addEnding('second', 'active', 'indicative', 'pluperfect', 'eram', 'erās', 'erat', 'erāmus', 'erātis', 'erant');
addEnding('second', 'passive', 'indicative', 'pluperfect', 'us eram', 'us erās', 'us erat', 'ī erāmus', 'ī erātis', 'ī erant');
addEnding('second', 'active', 'subjunctive', 'pluperfect', 'issem', 'issēs', 'isset', 'issēmus', 'issētis', 'issent');
addEnding('second', 'passive', 'subjunctive', 'pluperfect', 'us essem', 'us essēs', 'us esset', 'ī essēmus', 'ī essētis', 'ī essent');

addEnding('second', 'active', 'indicative', 'future perfect', 'erō', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('second', 'passive', 'indicative', 'future perfect', 'us erō', 'us eris', 'us erit', 'ī erimus', 'ī eritis', 'ī erunt');

$endings['second']['active']['imperative']['present']['thou'] = 'ē';
$endings['second']['passive']['imperative']['present']['thou'] = 'ēre';
$endings['second']['active']['imperative']['present']['ye'] = 'ēte';
$endings['second']['passive']['imperative']['present']['ye'] = 'ēminī';
$endings['second']['active']['imperative']['future']['yhou'] = 'ētō';
$endings['second']['passive']['imperative']['future']['yhou'] = 'ētor';
$endings['second']['active']['imperative']['future']['ye'] = 'ētōte';
$endings['second']['active']['imperative']['future']['he'] = 'ētō';
$endings['second']['passive']['imperative']['future']['he'] = 'ētor';
$endings['second']['active']['imperative']['future']['they'] = 'entō';
$endings['second']['passive']['imperative']['future']['they'] = 'entor';

$endings['second']['active']['infinitive']['present'] = 'ēre';
$endings['second']['passive']['infinitive']['present'] = 'ērī';
$endings['second']['active']['infinitive']['perfect'] = 'isse';
$endings['second']['passive']['infinitive']['perfect'] = 'us esse';
$endings['second']['active']['infinitive']['future'] = 'ūrus esse';
$endings['second']['passive']['infinitive']['future'] = 'um īrī';

$endings['second']['participle']['present'] = 'ēns';
$endings['second']['participle']['future'] = 'ūrus';
$endings['second']['participle']['perfect'] = 'us';
$endings['second']['participle']['gerundive'] = 'endus';

$endings['second']['gerund']['gentive'] = 'endī';
$endings['second']['gerund']['dative'] = 'endō';
$endings['second']['gerund']['accusative'] = 'endum';
$endings['second']['gerund']['ablative'] = 'endō';


$endings['second']['supine']['accusative'] = 'um';
$endings['second']['supine']['ablative'] = 'ū';



addEnding('third', 'active', 'indicative', 'present', 'ō', 'is', 'it', 'imus', 'itis', 'unt');
addEnding('third', 'passive', 'indicative', 'present', 'or', 'eris|ere', 'itur', 'imur', 'iminī', 'untur');
addEnding('third', 'active', 'subjunctive', 'present', 'am', 'ās', 'at', 'āmus', 'ātis', 'ant');
addEnding('third', 'passive', 'subjunctive', 'present', 'ar', 'āris|āre', 'ātur', 'āmur', 'āminī', 'antur');

addEnding('third', 'active', 'indicative', 'imperfect', 'ēbam', 'ēbās', 'ēbat', 'ēbāmus', 'ēbātis', 'ēbant');
addEnding('third', 'passive', 'indicative', 'imperfect', 'ēbar', 'ēbāris|ēbāre', 'ēbātur', 'ēbāmur', 'ēbāminī', 'ēbantur');
addEnding('third', 'active', 'subjunctive', 'imperfect', 'erem', 'erēs', 'eret', 'erēmus', 'erētis', 'erent');
addEnding('third', 'passive', 'subjunctive', 'imperfect', 'erer', 'erēris|erēre', 'erētur', 'erēmur', 'erēminī', 'erentur');

addEnding('third', 'active', 'indicative', 'future', 'am', 'ēs', 'et', 'ēmus', 'ētis', 'ent');
addEnding('third', 'passive', 'indicative', 'future', 'ar', 'ēris|ēre', 'ētur', 'ēmur', 'ēminī', 'entur');

addEnding('third', 'active', 'indicative', 'perfect', 'ī', 'istī', 'it', 'imus', 'istis', 'ērunt|ēre');
addEnding('third', 'passive', 'indicative', 'perfect', 'us sum', 'us es', 'us est', 'ī sumus', 'ī estis', 'ī sunt');
addEnding('third', 'active', 'subjunctive', 'perfect', 'erim', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('third', 'passive', 'subjunctive', 'perfect', 'us sim', 'us sīs', 'us sit', 'ī sīmus', 'ī sītis', 'ī sint');

addEnding('third', 'active', 'indicative', 'pluperfect', 'eram', 'erās', 'erat', 'erāmus', 'erātis', 'erant');
addEnding('third', 'passive', 'indicative', 'pluperfect', 'us eram', 'us erās', 'us erat', 'ī erāmus', 'ī erātis', 'ī erant');
addEnding('third', 'active', 'subjunctive', 'pluperfect', 'issem', 'issēs', 'isset', 'issēmus', 'issētis', 'issent');
addEnding('third', 'passive', 'subjunctive', 'pluperfect', 'us essem', 'us essēs', 'us esset', 'ī essēmus', 'ī essētis', 'ī essent');

addEnding('third', 'active', 'indicative', 'future perfect', 'erō', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('third', 'passive', 'indicative', 'future perfect', 'us erō', 'us eris', 'us erit', 'ī erimus', 'ī eritis', 'ī erunt');

$endings['third']['active']['imperative']['present']['thou'] = 'e';
$endings['third']['passive']['imperative']['present']['thou'] = 'ere';
$endings['third']['active']['imperative']['present']['ye'] = 'ite';
$endings['third']['passive']['imperative']['present']['ye'] = 'iminī';
$endings['third']['active']['imperative']['future']['thou'] = 'itō';
$endings['third']['passive']['imperative']['future']['thou'] = 'itor';
$endings['third']['active']['imperative']['future']['ye'] = 'itōte';
$endings['third']['active']['imperative']['future']['he'] = 'itō';
$endings['third']['passive']['imperative']['future']['he'] = 'itor';
$endings['third']['active']['imperative']['future']['they'] = 'untō';
$endings['third']['passive']['imperative']['future']['they'] = 'untor';

$endings['third']['active']['infinitive']['present'] = 'ere';
$endings['third']['passive']['infinitive']['present'] = 'ī';
$endings['third']['active']['infinitive']['perfect'] = 'isse';
$endings['third']['passive']['infinitive']['perfect'] = 'us esse';
$endings['third']['active']['infinitive']['future'] = 'ūrus esse';
$endings['third']['passive']['infinitive']['future'] = 'um īrī';

$endings['third']['participle']['present'] = 'ēns';
$endings['third']['participle']['future'] = 'ūrus';
$endings['third']['participle']['perfect'] = 'us';
$endings['third']['participle']['gerundive'] = 'endus';

$endings['third']['gerund']['genitive'] = 'endī';
$endings['third']['gerund']['dative'] = 'endō';
$endings['third']['gerund']['accusative'] = 'endum';
$endings['third']['gerund']['ablative'] = 'endō';

$endings['third']['supine']['accusative'] = 'um';
$endings['third']['supine']['ablative'] = 'ū';



addEnding('fourth', 'active', 'indicative', 'present', 'iō', 'īs', 'it', 'īmus', 'ītis', 'iunt');
addEnding('fourth', 'passive', 'indicative', 'present', 'ior', 'īris|īre', 'ītur', 'īmur', 'īminī', 'iuntur');
addEnding('fourth', 'active', 'subjunctive', 'present', 'iam', 'iās', 'iat', 'iāmus', 'iātis', 'iant');
addEnding('fourth', 'passive', 'subjunctive', 'present', 'iar', 'iāris|iāre', 'iātur', 'iāmur', 'iāminī', 'iantur');

addEnding('fourth', 'active', 'indicative', 'imperfect', 'iēbam', 'iēbās', 'iēbat', 'iēbāmus', 'iēbātis', 'iēbant');
addEnding('fourth', 'passive', 'indicative', 'imperfect', 'iēbar', 'iēbāris|iēbāre', 'iēbātur', 'iēbāmur', 'iēbāminī', 'iēbantur');
addEnding('fourth', 'active', 'subjunctive', 'imperfect', 'īrem', 'īrēs', 'īret', 'īrēmus', 'īrētis', 'īrent');
addEnding('fourth', 'passive', 'subjunctive', 'imperfect', 'īrer', 'īrēris|īrēre', 'īrētur', 'īrēmur', 'īrēminī', 'īrentur');

addEnding('fourth', 'active', 'indicative', 'future', 'iam', 'iēs', 'iet', 'iēmus', 'iētis', 'ient');
addEnding('fourth', 'passive', 'indicative', 'future', 'iar', 'iēris|iēre', 'iētur', 'iēmur', 'iēminī', 'ientur');

addEnding('fourth', 'active', 'indicative', 'perfect', 'ī', 'istī', 'it', 'imus', 'istis', 'ērunt|ēre');
addEnding('fourth', 'passive', 'indicative', 'perfect', 'us sum', 'us es', 'us est', 'ī sumus', 'ī estis', 'ī sunt');
addEnding('fourth', 'active', 'subjunctive', 'perfect', 'erim', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('fourth', 'passive', 'subjunctive', 'perfect', 'us sim', 'us sīs', 'us sit', 'ī sīmus', 'ī sītis', 'ī sint');

addEnding('fourth', 'active', 'indicative', 'pluperfect', 'eram', 'erās', 'erat', 'erāmus', 'erātis', 'erant');
addEnding('fourth', 'passive', 'indicative', 'pluperfect', 'us eram', 'us erās', 'us erat', 'ī erāmus', 'ī erātis', 'ī erant');
addEnding('fourth', 'active', 'subjunctive', 'pluperfect', 'issem', 'issēs', 'isset', 'issēmus', 'issētis', 'issent');
addEnding('fourth', 'passive', 'subjunctive', 'pluperfect', 'us essem', 'us essēs', 'us esset', 'ī essēmus', 'ī essētis', 'ī essent');

addEnding('fourth', 'active', 'indicative', 'future perfect', 'erō', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('fourth', 'passive', 'indicative', 'future perfect', 'us erō', 'us eris', 'us erit', 'ī erimus', 'ī eritis', 'ī erunt');

$endings['fourth']['active']['imperative']['present']['thou'] = 'ī';
$endings['fourth']['passive']['imperative']['present']['thou'] = 'īre';
$endings['fourth']['active']['imperative']['present']['ye'] = 'īte';
$endings['fourth']['passive']['imperative']['present']['ye'] = 'īminī';
$endings['fourth']['active']['imperative']['future']['thou'] = 'ītō';
$endings['fourth']['passive']['imperative']['future']['thou'] = 'ītor';
$endings['fourth']['active']['imperative']['future']['ye'] = 'ītōte';
$endings['fourth']['active']['imperative']['future']['he'] = 'ītō';
$endings['fourth']['passive']['imperative']['future']['he'] = 'ītor';
$endings['fourth']['active']['imperative']['future']['they'] = 'iuntō';
$endings['fourth']['passive']['imperative']['future']['they'] = 'iuntor';

$endings['fourth']['active']['infinitive']['present'] = 'īre';
$endings['fourth']['passive']['infinitive']['present'] = 'īrī';
$endings['fourth']['active']['infinitive']['perfect'] = 'isse';
$endings['fourth']['passive']['infinitive']['perfect'] = 'us esse';
$endings['fourth']['active']['infinitive']['future'] = 'ūrus esse';
$endings['fourth']['passive']['infinitive']['future'] = 'um īrī';

$endings['fourth']['participle']['present'] = 'iēns';
$endings['fourth']['participle']['future'] = 'ūrus';
$endings['fourth']['participle']['perfect'] = 'us';
$endings['fourth']['participle']['gerundive'] = 'iendus';

$endings['fourth']['gerund']['genitive'] = 'iendī';
$endings['fourth']['gerund']['dative'] = 'iendō';
$endings['fourth']['gerund']['accusative'] = 'iendum';
$endings['fourth']['gerund']['ablative'] = 'iendō';

$endings['fourth']['supine']['accusative'] = 'um';
$endings['fourth']['supine']['ablative'] = 'ū';



addEnding('mixed', 'active', 'indicative', 'present', 'iō', 'is', 'it', 'imus', 'itis', 'iunt');
addEnding('mixed', 'passive', 'indicative', 'present', 'ior', 'eris|ere', 'itur', 'imur', 'iminī', 'iuntur');
addEnding('mixed', 'active', 'subjunctive', 'present', 'iam', 'iās', 'iat', 'iāmus', 'iātis', 'iant');
addEnding('mixed', 'passive', 'subjunctive', 'present', 'iar', 'iāris|iāre', 'iātur', 'iāmur', 'iāminī', 'iantur');

addEnding('mixed', 'active', 'indicative', 'imperfect', 'iēbam', 'iēbās', 'iēbat', 'iēbāmus', 'iēbātis', 'iēbant');
addEnding('mixed', 'passive', 'indicative', 'imperfect', 'iēbar', 'iēbāris|iēbāre', 'iēbātur', 'iēbāmur', 'iēbāminī', 'iēbantur');
addEnding('mixed', 'active', 'subjunctive', 'imperfect', 'erem', 'erēs', 'eret', 'erēmus', 'erētis', 'erent');
addEnding('mixed', 'passive', 'subjunctive', 'imperfect', 'erer', 'erēris|erēre', 'erētur', 'erēmur', 'erēminī', 'erentur');

addEnding('mixed', 'active', 'indicative', 'future', 'iam', 'iēs', 'iet', 'iēmus', 'iētis', 'ient');
addEnding('mixed', 'passive', 'indicative', 'future', 'iar', 'iēris|iēre', 'iētur', 'iēmur', 'iēminī', 'ientur');

addEnding('mixed', 'active', 'indicative', 'perfect', 'ī', 'istī', 'it', 'imus', 'istis', 'ērunt|ēre');
addEnding('mixed', 'passive', 'indicative', 'perfect', 'us sum', 'us es', 'us est', 'ī sumus', 'ī estis', 'ī sunt');
addEnding('mixed', 'active', 'subjunctive', 'perfect', 'erim', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('mixed', 'passive', 'subjunctive', 'perfect', 'us sim', 'us sīs', 'us sit', 'ī sīmus', 'ī sītis', 'ī sint');

addEnding('mixed', 'active', 'indicative', 'pluperfect', 'eram', 'erās', 'erat', 'erāmus', 'erātis', 'erant');
addEnding('mixed', 'passive', 'indicative', 'pluperfect', 'us eram', 'us erās', 'us erat', 'ī erāmus', 'ī erātis', 'ī erant');
addEnding('mixed', 'active', 'subjunctive', 'pluperfect', 'issem', 'issēs', 'isset', 'issēmus', 'issētis', 'issent');
addEnding('mixed', 'passive', 'subjunctive', 'pluperfect', 'us essem', 'us essēs', 'us esset', 'ī essēmus', 'ī essētis', 'ī essent');

addEnding('mixed', 'active', 'indicative', 'future perfect', 'erō', 'eris', 'erit', 'erimus', 'eritis', 'erint');
addEnding('mixed', 'passive', 'indicative', 'future perfect', 'us erō', 'us eris', 'us erit', 'ī erimus', 'ī eritis', 'ī erunt');

$endings['mixed']['active']['imperative']['present']['thou'] = 'e';
$endings['mixed']['passive']['imperative']['present']['thou'] = 'ere';
$endings['mixed']['active']['imperative']['present']['ye'] = 'ite';
$endings['mixed']['passive']['imperative']['present']['ye'] = 'iminī';
$endings['mixed']['active']['imperative']['future']['thou'] = 'itō';
$endings['mixed']['passive']['imperative']['future']['thou'] = 'itor';
$endings['mixed']['active']['imperative']['future']['ye'] = 'itōte';
$endings['mixed']['active']['imperative']['future']['he'] = 'itō';
$endings['mixed']['passive']['imperative']['future']['he'] = 'itor';
$endings['mixed']['active']['imperative']['future']['they'] = 'iuntō';
$endings['mixed']['passive']['imperative']['future']['they'] = 'iuntor';

$endings['mixed']['active']['infinitive']['present'] = 'ere';
$endings['mixed']['passive']['infinitive']['present'] = 'ī';
$endings['mixed']['active']['infinitive']['perfect'] = 'isse';
$endings['mixed']['passive']['infinitive']['perfect'] = 'us esse';
$endings['mixed']['active']['infinitive']['future'] = 'ūrus esse';
$endings['mixed']['passive']['infinitive']['future'] = 'um īrī';

$endings['mixed']['participle']['present'] = 'iēns';
$endings['mixed']['participle']['future'] = 'ūrus';
$endings['mixed']['participle']['perfect'] = 'us';
$endings['mixed']['participle']['gerundive'] = 'iendus';

$endings['mixed']['gerund']['genitive'] = 'iendī';
$endings['mixed']['gerund']['dative'] = 'iendō';
$endings['mixed']['gerund']['accusative'] = 'iendum';
$endings['mixed']['gerund']['ablative'] = 'iendō';

$endings['mixed']['supine']['accusative'] = 'um';
$endings['mixed']['supine']['ablative'] = 'ū';


function validateForm() {
	return ($_SERVER['REQUEST_METHOD'] == 'POST') && $_POST['verb'] && $_POST['meaning'] && 
	       ($_POST['pres_stem'] || $_POST['perf_stem'] || $_POST['part_stem']);
}


$defaults['conjugation'] = $endings[0];
$defaults['verb'] = '';
$defaults['meaning'] = '';
$defaults['pres_stem'] = '';
$defaults['perf_stem'] = '';
$defaults['part_stem'] = '';
$defaults['isdep'] = '';

if (validateForm()) {
	$defaults['conjugation'] = $_POST['conjugation'];
	$defaults['verb'] = $_POST['verb'];
	$defaults['meaning'] = $_POST['meaning'];
	$defaults['pres_stem'] = $_POST['pres_stem'];
	$defaults['perf_stem'] = $_POST['perf_stem'];
	$defaults['part_stem'] = $_POST['part_stem'];
	$defaults['isdep'] = $_POST['isdep'];

}
?>

<script type="text/javascript">
function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}
</script>

<body>
<div id="container">
<div id="center">
<form action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" method="post">
<table align="center">
<caption>Latin Verb Conjugator</caption>
<tr class="separate-above">
<th>Conjugation</th>
<td>
<select name="conjugation">
<?php

foreach($endings as $conj => $aConj) {
	print "<option value=\"$conj\"";
	if ($conj == $_POST['conjugation']) {
		print " SELECTED";
	}
	print ">".ucfirst($conj)." Conjugation</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
	<th>Deponent</th>
	<td><input type="checkbox" name="isdep" value="Yes" <?php echo $defaults['isdep'] ? ' checked="checked"' : "" ?>/></td>
</tr>
<tr><th>Verb</th><td><input name="verb" type="text" value="<?php echo $defaults['verb']; ?>" /></td></tr>
<tr><th>Meaning</th><td><input name="meaning" type="text" value="<?php echo $defaults['meaning']; ?>" /></td></tr>
<tr><th>Present Stem</th><td><input name="pres_stem" type="text" value="<?php echo $defaults['pres_stem']; ?>" /></td></tr>
<tr><th>Perfect Stem</th><td><input name="perf_stem" type="text" value="<?php echo $defaults['perf_stem']; ?>" /></td></tr>
<tr><th>participle Stem</th><td><input name="part_stem" type="text" value="<?php echo $defaults['part_stem']; ?>" /></td></tr>
<tr class="separate-above"><td></td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>



</div>
</div>
<?php

if (validateForm()) {
	$sql = "BEGIN;\n";
	$conj = $_POST['conjugation'];
	if ($_POST['isdep']) {
		$conj .= '-dep';
	}
	foreach($endings[$_POST['conjugation']] as $voice => $aVoice) {
		if ($voice != 'active' && $voice != 'passive') {
			$words = array();

			foreach($aVoice as $tense => $ending) {
				$stem = $_POST['pres_stem'];
				if ($voice == 'supine' || ($voice == 'participle' && in_array($tense, array('perfect', 'future')))) {
					$stem = $_POST['part_stem'];
				}
				if ($stem) {
					$words[] = "'$stem$ending'";
				} else {
					$words[] = "NULL";
				}
			}

			$sql .= "INSERT INTO $voice VALUES('".$_POST['verb']."', ".implode(", ", $words).", '$conj');\n";
			continue;
		}
		foreach(array('indicative', 'subjunctive', 'imperative') as $mood) {
			if ($_POST['isdep'] && $voice == 'active') {
				continue;
			}
			foreach($endings[$_POST['conjugation']][$voice][$mood] as $tense => $aTense) {
				$stem = "";
				if ($mood == 'imperative' || in_array($tense, array('present', 'imperfect', 'future')) ) {
					$stem = $_POST['pres_stem'];
				} elseif (in_array($tense, array('perfect', 'pluperfect', 'future perfect'))) {
					if ($voice == 'active') {
						$stem = $_POST['perf_stem'];
					} elseif ($voice == 'passive') {
						$stem = $_POST['part_stem'];
					}
				}
				
				if (! $stem) {
					continue;
				}
				$sql .= "INSERT INTO verbs VALUES('".$_POST['verb']."', '".$_POST['meaning']."', ";
				$sql .= "'$voice', '$mood', '$tense', ";
				$words = array();
				foreach (array('I', 'thou', 'he', 'we', 'ye', 'they') as $person) {
					if (isset($aTense[$person])) {
						$tmp = explode('|', $aTense[$person]);
						$tmpw = array();
						foreach($tmp as $ending) {
							$tmpw[] = $stem.$ending;
						}
						$words[$person] = "'".implode('|', $tmpw)."'";
					} else {
						$words[$person] = 'NULL';
					}
				}
				$sql .= implode(', ', $words).", '$conj');\n";
			}
		}
		
		if (isset($aVoice['infinitive'])) {
			$sql .= "INSERT INTO infinitive VALUES('".$_POST['verb']."', '$voice', ";
			$words = array();
			foreach(array('present', 'future', 'perfect') as $tense) {
				$stem = "";
				if ($_POST['isdep'] && ( ($voice == 'active' && $tense != 'future') || 
				                         ($voice == 'passive' && $tense == 'future') )) {
				   $words[$tense] = 'NULL';
				} else {
					if ($tense == 'present') {
						$stem = $_POST['pres_stem'];
					} elseif ( ($tense == 'perfect') && ($voice == 'active')) {
						$stem = $_POST['perf_stem'];
					} else {
						$stem = $_POST['part_stem'];
					}
					
					if ($stem && isset($aVoice['infinitive'][$tense])) {
						$tmp = explode('|', $aVoice['infinitive'][$tense]);
						$tmpw = array();
						foreach($tmp as $ending) {
							$tmpw[] = $stem.$ending;
						}
						$words[$tense] = "'".implode('|', $tmpw)."'";
					} else {
						$words[$tense] = 'NULL';
					}
				}
			}
			$sql .= implode(', ', $words).", '$conj');\n";
		}
	}
	
	$sql .= "COMMIT;\n";
?>
<hr />
<div id="container">
<div id="center">

<textarea align="center" style='font-size:8pt;' cols="120" rows="10" wrap="off" id="sqls" onClick="SelectAll('sqls');">
<?php echo $sql; ?>
</textarea>
</div>
</div>
<?php
}
?>
</body>
</html>
